package com.example.demoserver.controller;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class test {
    public static void main(String[] args) {
        Connection conn = null;
        try {
            // db参数是你的数据库文件的路径，如果文件不存在，SQLite会创建一个新的数据库
            String url = "jdbc:sqlite:db.sqlite";
            // 创建一个数据库连接
            conn = DriverManager.getConnection(url);

            Statement stmt = conn.createStatement();
//            String sql = "CREATE TABLE IF NOT EXISTS inte_appalarm (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	alarmInfo text NOT NULL,\n"
//                    + "	alarmType integer NOT NULL,\n"
//                    + "	alarmTime text NOT NULL\n"
//                    + ");";
//            String sql1 = "CREATE TABLE IF NOT EXISTS inte_applog (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	appName text NOT NULL,\n"
//                    + "	appState integer NOT NULL,\n"
//                    + "	opTime text NOT NULL\n"
//                    + ");";
            String sql2 = "CREATE TABLE IF NOT EXISTS inte_appstate (\n"
                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
                    + "	appName text NOT NULL,\n"
                    + "	appState integer NOT NULL,\n"
                    + "	appFault integer NOT NULL\n"
                    + ");";
//            String sql3 = "CREATE TABLE IF NOT EXISTS inte_datapoint (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	gatewayId integer NOT NULL,\n"
//                    + "	pointTag text NOT NULL,\n"
//                    + "	pointUnit text,\n"
//                    + "	pointValue real NOT NULL,\n"
//                    + "	isBool integer NOT NULL,\n"
//                    + "	updateTime text NOT NULL\n"
//                    + ");";
//            String sql4 = "CREATE TABLE IF NOT EXISTS inte_gateway (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	gatewayName text NOT NULL,\n"
//                    + "	gatewayId text NOT NULL,\n"
//                    + "	mqttPassword text NOT NULL,\n"
//                    + "	gatewayState integer NOT NULL,\n"
//                    + "	createTime text NOT NULL,\n"
//                    + "	introduce text\n"
//                    + ");";
//            String sql5 = "CREATE TABLE IF NOT EXISTS inte_gatewaylog (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	logOperate text NOT NULL,\n"
//                    + "	hType text NOT NULL,\n"
//                    + "	logValue text NOT NULL,\n"
//                    + "	logTime integer NOT NULL\n"
//                    + ");";
//            String sql6 = "CREATE TABLE IF NOT EXISTS inte_identify (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	productName text NOT NULL,\n"
//                    + "	encodeType text NOT NULL,\n"
//                    + "	code text NOT NULL,\n"
//                    + "	encodeMode text NOT NULL,\n"
//                    + "	deviceName text NOT NULL,\n"
//                    + "	devicePlacementPosition text NOT NULL,\n"
//                    + "	ascribeCodeTime text NOT NULL,\n"
//                    + "	uploadCodeId text NOT NULL\n"
//                    + ");";
//                        String sql7 = "CREATE TABLE IF NOT EXISTS inte_goods (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	goodsName text NOT NULL,\n"
//                    + "	goodsClass text NOT NULL,\n"
//                    + "	goodsCode text NOT NULL\n"
//                    + ");";
//            String sql8 = "CREATE TABLE IF NOT EXISTS inte_saleorder (\n"
//                    + "	id INTEGER  PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	orderName text NOT NULL,\n"
//                    + "	goodsId INTEGER  NOT NULL,\n"
//                    + "	goodsNum INTEGER  NOT NULL,\n"
//                    + "	orderTime text NOT NULL,\n"
//                    + "	proStarTime text ,\n"
//                    + "	proEndTime text ,\n"
//                    + "	deliveryTime text ,\n"
//                    + "	orderState integer NOT NULL\n"
//                    + ");";
//            String sql9 = "CREATE TABLE IF NOT EXISTS inte_logistics (\n"
//                    + "	id INTEGER  PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	orderName text NOT NULL,\n"
//                    + "	logisticState INTEGER  NOT NULL,\n"
//                    + "	orderTime text NOT NULL,\n"
//                    + "	deliveryTime text ,\n"
//                    + "	saleId integer NOT NULL\n"
//                    + ");";
//              String sql10 = "CREATE TABLE IF NOT EXISTS inte_log (\n"
//                    + "	id INTEGER  PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	logInfo text NOT NULL,\n"
//                    + "	logType INTEGER  NOT NULL,\n"
//                    + "	logTime text NOT NULL\n"
//                    + ");";
            // 执行SQL语句，创建用户表
            //stmt.execute(sql);
            //stmt.execute(sql1);
            stmt.execute(sql2);
//            stmt.execute(sql3);
//            stmt.execute(sql4);
//            stmt.execute(sql5);
            //stmt.execute(sql7);
//            stmt.execute(sql8);
//            stmt.execute(sql9);
            //stmt.execute(sql10);
            //stmt.execute(sql);
//            String sql = "SELECT * from house_partstore where  proCompany like CONCAT('%','华北','%')";
//            stmt.execute(sql);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
            }
        }

    }

}
